$(document).ready(function() {
	console.log("进来了么？？？");
    collList.search();
	
})// document end

 var collList=new Vue({
		el : '#main',
		data : {
			home : '',
			majorlist : '',
			classlist : '',
		},
		
		methods : {
			search : function() {
				var _self = this;
				console.log("进来了么======");
				$.ajax({
					url : 'emp/scoll',
					type : 'post',
					dataType : 'json',
					success : function(data) {
						_self.home = data;
						console.log(_self.home);
					}
				})// ajax end
			},
			showmajor : function() {
				var _self = this;
				var collId=$("#coll").val();
				var checkText=$("#coll").find("option:selected").text();
				console.log("学院的id是===="+collId); 
				console.log("内容是===="+checkText); 
	
				console.log("进来了么>>>>");
				$.ajax({
					url : 'emp/major',
					type : 'post',
					dataType : 'json',
					data:{'collId':collId},
					success : function(data) {
						console.log(data);
						_self.majorlist= data;
						
					}
				})// ajax end
			},
			
			showclass : function() {
				var _self = this;
				var majorId=$("#major").val();
				var checkText=$("#major").find("option:selected").text();
				console.log("专业的id是===="+majorId); 
				console.log("内容是===="+checkText); 
	
				console.log("进来了么>>>>");
				$.ajax({
					url : 'emp/cls',
					type : 'post',
					dataType : 'json',
					data:{'majorId':majorId},
					success : function(data) {
						console.log(data);
						_self.classlist= data;
						
					}
				})// ajax end
			},
			stu : function(curr) {
				console.log("当前页是======"+curr);
				stuList.showstu(curr);
				
			},
			
		}//method end
	})//VUE end
//预览上传图片
function lookphoto() {
	var r= new FileReader();
	var f=document.getElementById('file').files[0];
	r.readAsDataURL(f);
	r.onload=function (e) {
	document.getElementById('stuPhoto').src=this.result;
	}
}

var stuList=new Vue({
	el : '#mm',
	data:{
		stulist:'',
	},
	methods : {
		showstu : function(curr){
			var _self = this;

			
			var formdate=new FormData($("#fm")[0]);
			formdate.append("currentPage",curr);
			console.log("当前页是======"+curr);
			$.ajax({
				url : 'stu/retrieval',
				data:formdate,
				type : 'post',
				dataType : 'json',
				contentType:false,
		        processData:false,
				success : function(data) {
					console.log(data);
					_self.stulist=data.list;
					laypage({
					     
						  cont: $("#page"),  //定义分页显示的容器
						  pages:data.totalPage,  //从后台查询得到总页数
						  curr:curr,     
						  skin: 'molv', 
						  skip:true, 
						  last:'末页',
						  groups:3,  
						  jump: function(obj, first){ 
						  console.log("==========================");
								
						    if(!first){   
						    	stuList.showstu(obj.curr);
						    }
						  }
						});
				}
			})//ajax end
		},
		del:function(){
			if(confirm("确认删除？")){
			var checkID = [];//定义一个空数组
			 $("input[name='stuno']:checked").each(function(i){//把所有被选中的复选框的值存入数组
			checkID[i] =$(this).val();
			console.log(checkID[i]);
			$(this).parents("tr").remove();
			 });
			 console.log(checkID);
			 $.ajax({
				 url:'stu/deletestu',
				type:'post',
				data:{"arr":checkID},
				dataType:'json',
				
				success:function(result){
				console.log(result.message);
				}	  
			 })
			 
			}
		},
		changeAllChecked:function(){
	
			console.log($("#allbox").attr("checked"));
			this.check=!this.check;
			$("tbody input").attr("checked",this.check);
			
		},
		
	}//methods结束
})//vue结束